<?php
namespace App\Service\AppService;
class MyDate  
{  
    /**
     * 计算时间戳之间的天数，不到一天算一天，整点算一天
     *
     * @param  int $start $end
     * @return string
     */
    public static function diffBetweenTwoDays($start,$end) {
        if ($start>$end) {
            $tmp = $start;
            $start = $end;
            $end = $tmp;
        }
    
        return floor(($end + 28800) / 86400) - floor(($start + 28800) / 86400) + 1;
    }
    
    /**
     * 获取MYSQL date string
     * @param string $dateFields
     * @param string $format
     */
    public static function getDateByMysqlDateFields( string $dateFields = null ,string $format = 'Y-m-d' )
    {
        if( empty($dateFields) ) {
            return '';
        }
    
        if( in_array($dateFields, ['0000-00-00 00:00:00','1969-11-30 00:00:00']) ) {
            return '';
        }
        return date($format,strtotime($dateFields));
    }
}  